package ch.zbw.pra.sysventory.domain.model;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import ch.zbw.pra.sysventory.domain.util.TimeStampGenerator;

public class ExampleScanVersion {
	private Scanversion scanversion;
	private Computer computer;
	// private Nic nic;
	private OperatingSystem operatingSystem;
	// private Printer printer;
	private Processor processor;
	// private Software software;
	private List<VendorSoftware> vendorsOfTheSoftware;
	private List<Software> softwares;
	private List<Nic> nics;
	private List<Printer> printers;

	public ExampleScanVersion() {
		super();
		this.scanversion = new Scanversion();
		this.computer = new Computer();
		// this.nic = new Nic();
		this.operatingSystem = new OperatingSystem();
		initOperatingSystem();
		// this.printer = new Printer();
		this.processor = new Processor();
		initProcessor();
		// this.software = new Software();
		this.vendorsOfTheSoftware = new ArrayList<VendorSoftware>();
		fillSoftwareVendorList();
		this.softwares = new ArrayList<Software>();
		fillSoftwaresList();
		this.nics = new ArrayList<Nic>();
		fillNicsList();
		this.printers = new ArrayList<Printer>();
		fillPrintersList();

		// the examplescanversion (this) represents for test the scanversion,
		// thats because same methods in this body
		this.scanversion.setComputer(this.computer);
		this.setNumberOfScanversion();
		this.setTimestampScanversion();
		this.computer.setHostNameComputer("PC 1");
		this.computer.setNics(nics);
		this.computer.setOs(operatingSystem);
		this.computer.setPrinters(printers);
		this.computer.setProcessor(this.processor);
		this.computer.setRamComputer("4096");
		this.computer.setSidComputer("SID-4566-35678-45-4567-89-7654-5532-987.5000");
		this.computer.setSoftwares(softwares);
		this.computer.setTypeComputer("Notebook");
	}

	public void fillSoftwareVendorList() {
		VendorSoftware testSoftwareVendor = new VendorSoftware();
		for (int j = 0; j < 10; j++) {
			testSoftwareVendor.setNameVendorSoftware("SoftwareHersteller" + j);
			vendorsOfTheSoftware.add(testSoftwareVendor);
		}
	}

	public void fillSoftwaresList() {
		Software testSoftware = new Software();
		for (int i = 0; i < 10; i++) {

			testSoftware.setNameSoftware("Softwarename" + i);
			testSoftware.setVendor(vendorsOfTheSoftware.get(i));
			testSoftware.setVersionSoftware("SoftwareVersion" + i * 33);
			softwares.add(testSoftware);
		}
	}

	public void fillNicsList() {
		Nic testNic = new Nic();

		for (int k = 0; k < 4; k++) {
			testNic.setDhcpNic("true");
			testNic.setIpv4Nic("122.12.12.1" + k);
			testNic.setIpv6Nic("23:FF:AA:5" + k);
			testNic.setMacAdressNic("EEDD12347" + k);
			testNic.setNameNic("NicName" + k);
			testNic.setStandardGatewayNic("10.0.1.5");
			testNic.setSubnetNic("10.20.20.21");
			nics.add(testNic);
		}
	}

	public void initOperatingSystem() {
		operatingSystem.setArchitecture32Bit64BitOperatingSystem("32bit");
		operatingSystem.setBuildOperatingSystem("5.1.2600.2180");
		operatingSystem.setNameOperatingSystem("Microsoft Windows XP");
	}

	public void fillPrintersList() {
		Printer testPrinter = new Printer();

		for (int l = 0; l < 7; l++) {
			testPrinter.setDriverNamePrinter("PhysicalPrinterName" + l);
			testPrinter.setDriverVersionPrinter("ManufacterOfPrinter" + l);
			testPrinter.setNamePrinter("34.4" + l);
			printers.add(testPrinter);
		}
	}

	public void initProcessor() {
		this.processor.setClockProcessor(3700);
		this.processor.setCoresProcessor(4);
		this.processor.setFamilyProcessor("sandy-Bridge");
		this.processor.setNameProcessor("i7");
	}

	// ScanVersionMethods
	public int getNumberOfScanversion() {
		return this.scanversion.getNumberOfScanversion();
	}

	public void setNumberOfScanversion() {
		this.scanversion.setNumberOfScanversion(1);
	}

	public Timestamp getTimestampScanversion() {
		return this.scanversion.getTimestampScanversion();
	}

	public void setTimestampScanversion() {
		TimeStampGenerator tsg = new TimeStampGenerator();
		Timestamp nowIs = tsg.getCurrentTimeStamp();
		this.scanversion.setTimestampScanversion(nowIs);
	}

	public Computer getComputer() {
		return computer;
	}

	public void setComputer(Computer computer) {
		this.computer = computer;
	}
}
